package com.bazaaroid.server.gae.api.resources.partner;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import com.bazaaroid.server.gae.core.dao.UserDAO;
import com.bazaaroid.server.gae.core.dao.partner.CategoryDAO;
import com.bazaaroid.server.gae.core.dao.partner.DiscountDAO;
import com.bazaaroid.server.gae.core.dao.partner.LocationDAO;
import com.bazaaroid.server.gae.core.dao.partner.PartnerDAO;
import com.bazaaroid.server.gae.core.dao.partner.ProductDAO;
import com.bazaaroid.server.gae.core.dao.partner.TagDAO;
import com.bazaaroid.server.gae.core.dto.partner.AllEntitiesDTO;
import com.bazaaroid.server.gae.core.ioc.GuiceFactory;

@Path("/all/")
public class AllEntitiesResource {
	@GET
	@Produces( { "application/xml", "application/json" })
	@Path("/")
	public AllEntitiesDTO getAllEntitites() {
		PartnerDAO partnerDAO = GuiceFactory.getInjector()
			.getInstance(PartnerDAO.class);
		LocationDAO locationDAO = GuiceFactory.getInjector()
			.getInstance(LocationDAO.class);
		ProductDAO productDAO = GuiceFactory.getInjector()
			.getInstance(ProductDAO.class);
		DiscountDAO discountDAO = GuiceFactory.getInjector()
			.getInstance(DiscountDAO.class);
		CategoryDAO categoryDAO = GuiceFactory.getInjector()
			.getInstance(CategoryDAO.class);
		TagDAO tagDAO = GuiceFactory.getInjector()
			.getInstance(TagDAO.class);
		UserDAO userDAO = GuiceFactory.getInjector()
			.getInstance(UserDAO.class);

		return new AllEntitiesDTO(partnerDAO.getAll(), locationDAO.getAll(),
				productDAO.getAll(), discountDAO.getAll(),
				categoryDAO.getAll(), tagDAO.getAll(),
				userDAO.getAll());
	}
}
